// /*
//  * @Author: WanYiMing
//  * @Date:2024-07-13-22:49
//  * @Description:
//  */

using System;
using System.Collections.Generic;
using Code.DataManager.Model;
using Code.GameLogic.BaseClass.Model;
using Code.GameLogic.XianJian;

namespace Code.DataManager.Converter
{
    public class XianJianConvertImpl : ISettingConvert<Dictionary<string, XianJianBo>, XianJianJsonBo>
    {
        public Dictionary<string, XianJianBo> ConvertToBo(XianJianJsonBo xianJianJson)
        {
            throw new NotImplementedException();
        }

        public Dictionary<string, XianJianBo> ConvertToBo(XianJianJsonBo xianJianJson, Dictionary<string, XianJianBo> result)
        {
            var xjList = xianJianJson.XjList;
            foreach (var xj in xjList)
            {
                var xianJianBo = Convert(xj);
                result[xianJianBo.BaseDescription.TypeCode] = xianJianBo;
            }

            return result;
        }

        private XianJianBo Convert(XianJianJsonBo.Xj xj)
        {
            XianJianBo xianJianBo = new XianJianBo(new BaseDescription(xj.type, xj.name));
            xianJianBo.MainBehavior= Convert_MainBehavior(xj.mainBehavior);
            xianJianBo.JianQi= Convert_JianQi(xj.jianQiBo);
            xianJianBo.AssistCell = xj.assistCell;
            xianJianBo.AssistBehaviors = new List<AssistBehavior>();
            xj.assistBehaviors.ForEach(e=>xianJianBo.AssistBehaviors.Add(Convert_AssistBehaviors(e)));
            return xianJianBo;
        }

        private AssistBehavior Convert_AssistBehaviors(XianJianJsonBo.Xj.AssistBehavior xjAssistBehaviors)
        {
            AssistBehavior assistBehavior = new AssistBehavior();
            assistBehavior.AssistCode = xjAssistBehaviors.assistCode;
            assistBehavior.AssistTypeEnum = (AssistTypeEnum)xjAssistBehaviors.assistTypeEnum;
            assistBehavior.Skill = xjAssistBehaviors.skill;
            assistBehavior.Priority = xjAssistBehaviors.priority;
            return assistBehavior;
        }

        private JianQi Convert_JianQi(XianJianJsonBo.Xj.JianQiBo xjJianQiBo)
        {
            JianQi jianQi = new JianQi();
            jianQi.TrailStyle = xjJianQiBo.trailStyle;
            jianQi.JqFlySpeed = xjJianQiBo.jqFlySpeed;
            return jianQi;
        }

        private MainBehavior Convert_MainBehavior(XianJianJsonBo.Xj.MainBehavior xjMainBehavior)
        {
            var convertMainBehavior = new MainBehavior();
            convertMainBehavior.Act = xjMainBehavior.act;
            convertMainBehavior.Skill = xjMainBehavior.skill;
            convertMainBehavior.Area = xjMainBehavior.area;
            convertMainBehavior.XjFlySpeed = xjMainBehavior.xjFlySpeed;
            convertMainBehavior.Asp = xjMainBehavior.asp;
            return convertMainBehavior;

        }
        
        
        
        
    }
}